IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_AuthZUserRoleMapping_AuthZUser]') AND parent_object_id = OBJECT_ID(N'[dbo].[AuthZUserRoleMapping]'))
ALTER TABLE [dbo].[AuthZUserRoleMapping] DROP CONSTRAINT [FK_AuthZUserRoleMapping_AuthZUser]
GO

IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_AuthZUserRoleMapping_Role]') AND parent_object_id = OBJECT_ID(N'[dbo].[AuthZUserRoleMapping]'))
ALTER TABLE [dbo].[AuthZUserRoleMapping] DROP CONSTRAINT [FK_AuthZUserRoleMapping_Role]
GO

/****** Object:  Table [dbo].[AuthZUserRoleMapping]    Script Date: 08/05/2009 14:20:27 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[AuthZUserRoleMapping]') AND type in (N'U'))
DROP TABLE [dbo].[AuthZUserRoleMapping]
GO

/****** Object:  Table [dbo].[AuthZUserRoleMapping]    Script Date: 08/05/2009 14:20:27 ******/
SET ANSI_NULLS ON
GO

CREATE TABLE [dbo].[AuthZUserRoleMapping](
	[AuthZUserRoleMappingID] [int] IDENTITY(1,1) NOT NULL,
	[AuthZUserID] [int] NOT NULL,
	[RoleID] [int] NOT NULL,
	[CreatedBy] [nvarchar](50) NOT NULL,
	[CreatedDate] [datetime] NOT NULL,
	[UpdatedBy] [nvarchar](50) NULL,
	[UpdatedDate] [datetime] NULL,
 CONSTRAINT [PK_AuthZUserRoleMapping] PRIMARY KEY CLUSTERED 
(
	[AuthZUserRoleMappingID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]

GO

ALTER TABLE [dbo].[AuthZUserRoleMapping]  WITH CHECK ADD  CONSTRAINT [FK_AuthZUserRoleMapping_AuthZUser] FOREIGN KEY([AuthZUserID])
REFERENCES [dbo].[AuthZUser] ([AuthZUserID])
GO

ALTER TABLE [dbo].[AuthZUserRoleMapping] CHECK CONSTRAINT [FK_AuthZUserRoleMapping_AuthZUser]
GO

ALTER TABLE [dbo].[AuthZUserRoleMapping]  WITH CHECK ADD  CONSTRAINT [FK_AuthZUserRoleMapping_Role] FOREIGN KEY([RoleID])
REFERENCES [dbo].[Role] ([RoleID])
GO

ALTER TABLE [dbo].[AuthZUserRoleMapping] CHECK CONSTRAINT [FK_AuthZUserRoleMapping_Role]
GO


